package com.ly.lypopupwindowdemo.views;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

import com.ly.lypopupwindowdemo.R;
import com.ly.lypopupwindowdemo.util.Utils;

import org.joda.time.DateTime;

import java.util.List;

/**
 * Created by liying on 2017/8/18.
 */

public class MonthView extends View {

    Paint lyPaint;
    private int mWidth;
    private int mHeight;
    private List<DateTime> monthDateTimeList;

    protected List<Rect> mRectList;//点击用的矩形集合




    public MonthView(Context context) {
       this(context,null);
    }

    public MonthView(Context context, @Nullable AttributeSet attrs) {
        this(context,attrs,0);
    }

    public MonthView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        //monthCalendar = Utils.getMonthCalendar()

        lyPaint = getPaint(Color.GRAY,20);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        mWidth = getWidth();//view的宽度
        mHeight = getHeight();//view的高度
        mRectList.clear();

//        lyPaint.setAntiAlias(true);
//        lyPaint.setColor(getResources().getColor(R.color.gray_666666));
//        lyPaint.setStyle(Paint.Style.STROKE);
//        lyPaint.setStrokeWidth(10);
//
//        canvas.drawRect(60,90,getWidth()-60,1000,lyPaint);
        for (int i=0;i<6;i++){
            for (int j=0;j<7;j++){
                Rect rect = new Rect(j*mWidth/7,i*mHeight/6,j*mWidth/7+mWidth/7,i*mHeight/6+mHeight/6);
                mRectList.add(rect);

                canvas.drawRect(rect,lyPaint);
            }
        }
    }
    private Paint getPaint(int paintColor,float paintSize){
        Paint paint = new Paint();
        paint.setColor(paintColor);
        paint.setAntiAlias(true);
        paint.setTextSize(paintSize);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(3);
        paint.setTextAlign(Paint.Align.CENTER);
        return paint;
    }
}
